package entity;

import java.io.Serializable;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Sebas
 */
@Entity
@Table(name = "song")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Song.findAll", query = "SELECT s FROM Song s"),
    @NamedQuery(name = "Song.findByIdSong", query = "SELECT s FROM Song s WHERE s.idSong = :idSong"),
    @NamedQuery(name = "Song.findBySongDuration", query = "SELECT s FROM Song s WHERE s.songDuration = :songDuration")})
public class Song implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id_song")
    private Integer idSong;
    @Basic(optional = false)
    @Lob
    @Column(name = "song_title")
    private String songTitle;
    @Basic(optional = false)
    @Column(name = "song_duration")
    private float songDuration;
    @JoinColumn(name = "soundtrack_id_sountrack", referencedColumnName = "id_sountrack")
    @ManyToOne(optional = false)
    private Soundtrack soundtrackIdSountrack;
    @JoinColumn(name = "artist_id_artist", referencedColumnName = "id_artist")
    @ManyToOne(optional = false)
    private Artist artistIdArtist;

    public Song() {
    }

    public Song(Integer idSong) {
        this.idSong = idSong;
    }

    public Song(Integer idSong, String songTitle, float songDuration) {
        this.idSong = idSong;
        this.songTitle = songTitle;
        this.songDuration = songDuration;
    }

    public Integer getIdSong() {
        return idSong;
    }

    public void setIdSong(Integer idSong) {
        this.idSong = idSong;
    }

    public String getSongTitle() {
        return songTitle;
    }

    public void setSongTitle(String songTitle) {
        this.songTitle = songTitle;
    }

    public float getSongDuration() {
        return songDuration;
    }

    public void setSongDuration(float songDuration) {
        this.songDuration = songDuration;
    }

    public Soundtrack getSoundtrackIdSountrack() {
        return soundtrackIdSountrack;
    }

    public void setSoundtrackIdSountrack(Soundtrack soundtrackIdSountrack) {
        this.soundtrackIdSountrack = soundtrackIdSountrack;
    }

    public Artist getArtistIdArtist() {
        return artistIdArtist;
    }

    public void setArtistIdArtist(Artist artistIdArtist) {
        this.artistIdArtist = artistIdArtist;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idSong != null ? idSong.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Song)) {
            return false;
        }
        Song other = (Song) object;
        if ((this.idSong == null && other.idSong != null) || (this.idSong != null && !this.idSong.equals(other.idSong))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Song[ idSong=" + idSong + " ]";
    }
    
}
